package com.sunfeng.mianshi;

import java.util.Properties;

/**
 * @Author : 清风冷影
 * @Description: 饿汉式 是不存在线程安全问题的
 * @Date : 2021/11/18  20:32
 */

public class Singleton3 {

    private static final Singleton3 INSTANCE;

    private String info;

    static {
        try {

            Properties properties = new Properties();

            properties.load(Singleton3.class.getClassLoader().getResourceAsStream("application.properties"));

            INSTANCE = new Singleton3(properties.getProperty("info"));

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

    private Singleton3(String info) {
        this.info = info;
    }

    public static Singleton3 getInstance() {
        return INSTANCE;
    }

    @Override
    public String toString() {
        return "Singleton3{" +
                "info='" + info + '\'' +
                '}';
    }
}
